
$(document).ready(function(){
//		var $rongMH = $(window).width();
//		var $caoMH = $(window).height();
//		var $rong = $(window).width()*70/100;
		var $cao = $(window).width()/25;
		var $vitri = $(window).width()*15/100;
		var $caoImg = $(window).width()/9;
		
		$('.DLink').css({'margin-top': $cao + 'px'});
		/* Chua show anh va thong tin ben phai */
		$('.detail').css({'height':$caoImg*4+'px'});
		/* Thong tin san pham */
		$('.imgPro').css({'height': $caoImg*4+'px', 'width':'50%'});
		var $rong1 = $('.imgPro').width();
		$('.infoPro').css({'height':$caoImg*4+'px', 'width': '50%', 'position':'relative','top':-$caoImg*4+'px', 'left':$rong1+'px'});
		/* Dac diem noi bat va dieu kien */
		$('.feature').css({'width':'40%','position':'relative'});
		var $cao1 = $('.feature').height();
		$('.condition').css({'width': '50%', 'position':'relative','left':$rong1+'px', 'top': -$cao1+'px'});
		var $soCao1 = $('.feature').height();
		var $soCao2 = $('.condition').height();
		var $total;
		if($soCao1 > $soCao2)
			$total = $soCao1;
		else $total = $soCao2;
		$('.fea_con').height($total + 15);
		/* show anh */
		$('.show').css({'width':'80%', 'height':'80%', 'left':'10%', 'top':'3%'});
		var $rongshow = $('.show').width();
		var $caoshow = $('.show').height();
		$('.show img').css({'width':$rongshow+'px', 'height':$caoshow+'px'});
		var $countImg = $('.show').find('img').length;
		var $rongThumb = ($('.imgPro').width() - 32)/$countImg;
		
		$('.thumb').css({'margin-top': '5%','height':'12%'});
		
		/* Ham slide show -------------------------------------*/
		$(function(){
			// Xác định số lượng hình của slide
			var count = $('.show').find('img').length;
			var str = [];
					
			for(var x=0; x < count ;x++){
				str.push($('.show IMG:eq(' + x + ')').attr("src"));
			}
			for(var x=0; x < count ;x++){
				$('.thumb').append("<img src='"+ str[x] +"'/>");
			}
			$('.thumb IMG').css({'width': $rongThumb/1.3+'px', 'height':'100%','padding':'2px'});
			
		});
		
		/* Cho trinh dien slideShow 
		 * 
		 * 
		 * 
		 * ------------------------------*/
		var countpic = 0;
		var checkCount = $('.show').find('img').length;
		/* Xu ly chuyen hinh */
		function showPic(){
			if(countpic==checkCount-1){
				countpic=-1;
			}
			countpic++;
			$('.show IMG').stop().animate({opacity:0});
			$('.show IMG:eq(' + countpic + ')').stop().animate({opacity:1});
		}
		/* hoan doi picture thong qua time*/
		function swapPic(){
			timeinterval = 4000;
			play = setInterval(showPic,timeinterval);
		}
		/* Click vao Thumb nho o duoi thi hien hinh tuong ung */
		function clickPic(){
			$('.thumb IMG').click(function(){
				countpic = $('.thumb IMG').index(this);
				$('.show IMG').stop().animate({opacity:0});
				$('.show IMG:eq(' + countpic + ')').stop().animate({opacity:1});
			});
		}
		/* Xu ly khi dua con tro vao khung chua Picture va Thumb */
		function hoverThumb(){
			$('.show').hover(
				function(){clearInterval(play);}, 
				function(){swapPic();});
		}
		/* Ham thuc thi chinh */
		$(function(){
			$('.show IMG:first-child').css({opacity:1});
			swapPic();
			clickPic();
			hoverThumb();
		});
		
		/* Ki Thuat paging
		 * 
		 * 
		 * */
		$(function(){
			
			
		});
		
		
		
});

